package com.my.util;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.stream.Collectors;

public class FileUtils {


    public static String loadLuaScript(String fileName){

        ClassLoader classLoader = FileUtils.class.getClassLoader();
        String result = "";
        try{
            InputStream inputStream = classLoader.getResourceAsStream(fileName);
            if(inputStream == null){
                System.out.println("================= classLoader.getResourcesAsStream is null");
                return result;
            }
            result = new BufferedReader(new InputStreamReader(inputStream))
                    .lines().collect(Collectors.joining(System.lineSeparator()));
        }catch (Exception e){
            e.printStackTrace();
        }


        return result;

    }
}
